<template>
  <div>
    <center>
      <div class="c_title">
        <div><i class="el-icon-message-solid" style="color: red"></i></div>
        <div>
          <p>维数金融将根据您填写的信息进行初步审核，您填写的信息资料越真实详尽，您申请融资的审批通过率越高。同时，我们有严格的用户信息操作规范.</p>
          <p>确保您的隐私不被泄露，请勿填写虚假信息。</p>
        </div>
      </div><br><br>
    </center>
    <el-form ref="form" :inline="true" :model="form"  label-width="80px">
      <el-form-item label="租房合同编号" prop="cfContractNo">
        <el-input v-model="form.cfContractNo" disabled="true" placeholder="请输入租房合同编号"  />
      </el-form-item>
      <el-form-item  >
        <el-button type="primary" @click="gethouse">租房合同查询</el-button>
      </el-form-item>
      <br>
      <el-form-item label="承租房间" prop="roomName">
        <el-input v-model="form.roomName" disabled="true" placeholder="请输入承租房间"  />
      </el-form-item><br>
      <el-form-item label="房产编号" prop="houseId">
        <el-input v-model="form.houseId" disabled="true" placeholder="请输入房产编号"  />
      </el-form-item>
      <el-form-item label="租客姓名" prop="tenantName">
        <el-input v-model="form.tenantName" disabled="true" placeholder="请输入租客姓名"  />
      </el-form-item><br>
      <el-form-item label="租客手机号" prop="tenantPhone">
        <el-input v-model="form.tenantPhone" disabled="true" placeholder="请输入租客手机号"  />
      </el-form-item>
      <el-form-item label="租客身份证号" prop="tenantCardNo">
        <el-input v-model="form.tenantCardNo" disabled="true" placeholder="请输入租客身份证号"  />
      </el-form-item><br>
      <hr>
      <el-row><el-col :span="12">>
        <el-form-item label="金融产品选择" prop="productId">
          <el-select v-model="form.productId" placeholder="请选择"  @change="getproduct">
            <el-option  v-for="item in product"
                        :key="item.id"
                        :value="item.id"
                        :label="item.jrProductName" ></el-option>
          </el-select>
        </el-form-item>
      </el-col>
        <el-col :span="4">
          <el-form-item label="公寓承担" prop="businessRate">
            <el-input v-model="form.businessRate" style="width: 50px"></el-input>%
          </el-form-item></el-col>
        <el-col :span="4">
          <el-form-item label="租客承担" prop="tenantRate">
            <el-input v-model="form.tenantRate" style="width: 50px"></el-input>%
          </el-form-item></el-col>
        <el-col :span="4">
          <el-form-item label="年利率" prop="rate">
            <el-input v-model="form.rate" style="width: 50px"></el-input>%
          </el-form-item></el-col>
      </el-row><br>
      <el-row><el-col :span="12">
        <el-form-item label="借款金额" prop="loanAmount">
          <el-input v-model="form.loanAmount" style="width: 400px"></el-input>
        </el-form-item>
      </el-col>
        <el-col :span="12">
          <el-form-item label="年一次性服务费率" prop="serviceFee">
            <el-input v-model="form.serviceFee" style="width: 300px"></el-input>%
          </el-form-item>
        </el-col></el-row>
      <el-row><el-col :span="12">
        <el-form-item label="借款期限" prop="periods">
          <el-input v-model="form.periods" disabled="true" style="width: 400px"></el-input>
        </el-form-item>
      </el-col>
        <el-col :span="12">
          <el-form-item label="授信额度" prop="creditLine">
            <el-input v-model="form.creditLine" disabled="true" style="width: 300px"></el-input>
          </el-form-item>
        </el-col></el-row>
      <el-row><el-col :span="12">
        <el-form-item label="备注" prop="remark">
          <el-input type="textarea" rows="6" placeholder="请输入内容" v-model="form.remark" style="width: 600px;"></el-input>
        </el-form-item>
      </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" @click="submitForm">提交申请</el-button>
      </el-form-item>
    </el-form>
    <el-dialog title="租房合同查询" :visible.sync="dialogFormVisible">
      <el-form :model="roomlist"  :inline="true">
        <el-form-item label="租客姓名" :label-width="formLabelWidth">
          <el-input v-model="roomlist.tenantName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item  >
          <el-button type="primary" @click="gethouselist">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table :data="tableData">
        <el-table-column property="tenantName" label="租客姓名" width="150"></el-table-column>
        <el-table-column property="tenantPhone" label="租客手机号" width="200"></el-table-column>
        <el-table-column property="tenantCardNo" label="租客身份证"></el-table-column>
        <el-table-column
          fixed="right"
          label="操作"
          width="100">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small">选中</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="roomlist.pageNum"
        :limit.sync="roomlist.pageSize"
        @pagination="gethouselist"
      />
    </el-dialog>
  </div>
</template>

<script>
import {listcontract,listproduct,listSfLoan,productByid,SaveInstallMent} from "@/api/message/installment";

export default {
  name: "house",
  data(){
    return{
      dialogFormVisible2:false,
      estate:'',
      loan:true,
      form:{
        creditLine:'',
        periods:'',
      },
      total:0,
      tableData2:[],
      product:[],
      roomlist:{
        pageSize:5,
        pageNum:1,
        tenantName:''
      },
      dialogFormVisible:false,
      formLabelWidth: '120px'
    }
  },
  methods:{
    submitForm(){
      console.log(this.form)
      SaveInstallMent(this.form).then(res=>{
        if (res.data.code===200){
          this.$message.success("添加成功")
          this.$router.push("/message/index")
        }else {
          this.$message.error("添加失败")
        }
      })
    },
    sum(){
      console.log(this.form)
      listSfLoan(this.form).then(res=>{
        console.log(res)
        this.loan=false;
        this.tableData2=res.dataList.sfLoan;
        this.form.payAbleCount=res.dataList.payAbleCount;
        this.form.rePaymentCount=res.dataList.rePaymentCount;
        this.form.serCharge=res.dataList.serCharge;
        this.form.interestCount=res.dataList.interestCount;

      })
    },
    getproduct(){
      productByid(this.form.productId).then(res=>{
        this.form.creditLine=res.creditLine;
        this.form.periods=res.instalmentPeriod;
        console.log(this.form)
      })
    },
    handleClick(row){
      console.log("+++++++++++++++++++++++++++")
      this.form=row;
      this.form.startDate =row.leaseStartTime
      this.form.endDate =row.leaseEndTime
      console.log(this.form)
      console.log("+++++++++++++++++++++++++++")
      this.dialogFormVisible=false;
    },
    gethouselist(){
      listcontract(this.roomlist).then(res =>{
        this.tableData = res.list;
        this.total = res.total;
      })
    },
    gethouse(){
      this.dialogFormVisible=true;
    },
    getlistproduct(){
      listproduct().then(res=>{
        this.product=res;
      })
    }
  },
  created() {
    this.gethouselist();
    this.getlistproduct();
  }
}
</script>

<style scoped>
.c_title {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  background: #fcf0c6;
  padding: 20px 0px;
  line-height: 20px;
  font-weight: bold;
}
.c_title div:nth-child(2) p:nth-child(2){
  color: red;
}
</style>
